import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let store = new Vuex.Store({
  state:{
    user:{},
    index:0,
    items:[
      {
        "id":"1",
        "question":"首先，告诉我你的名字",
        "type":"input",
        "options":["命","运","今日运势"]
      },
      {
        "id":"2",
        "question":"请选择你的性别",
        "type":"selection",
        "options":["男","女"]
      },
      {
        "id":"3",
        "question":"下面，确认一下你的出生日期吧",
        "type":"date",
        "options":["命","运","今日运势"]
      },
      {
        "id":"4",
        "question":"收到，请选择你的出生地点",
        "type":"address",
        "options":["命","运","今日运势"]
      },
      {
        "id":"5",
        "question":"好的，请问你今天想算算哪方面的情况呢？",
        "type":"selection",
        "options":["命","运","今日运势"]
      },
      {
        "id":"6",
        "question":"明白，请问你是想算命势还是运势？",
        "desc":"命势就是俗称的命，运势，就是俗称的运",
        "type":"selection",
        "options":["命","运","今日运势"]
      },
      {
        "id":"7",
        "question":"命宫内有天同平和,你是个心地善良,但喜欢安逸,很有文化气息,也喜欢吃喝玩乐?",
    
        "type":"selection",
        "options":["是","否"]
      },
      {
        "id":"8",
        "question":"贪狼星化权入疾厄宫,容易得肝胆方面的毛病,脾胃不好?",
        "type":"selection",
        "options":["是","否"]
      },
      {
        "id":"9",
        "question":"好的,请选择一下你的职业",
        "type":"selection",
        "options":["教师","公务员","学生"]
      },
      {
        "id":"10",
        "question":"通过智能分析,我已经为你生成了一份关于2019年事业运势发展的分析报告",
        "type":"selection",
        "options":["揭晓报告"]
      },
      {
        "id":"11",
        "title":"2019运势报告",
        "question":"您好，欢迎使用算命大师，算命占卜作为华夏民族的一种民俗文化由来已久，是从古代沿袭至今的一种文化现象，一种择吉避凶的术数，一种广泛流传的民俗。中国算命术的发展兴盛有着深刻的社会基础，古代民间算命先生根据八字推断一生命运的民间活动，将人的出生年、月、日、时各配以天干、地支，每项两字，依次排列成八个字，俗称八字算命，然后找出其所属五行，再以相生相克之说来推断其祸福寿夭，这就是芸芸众生对命运的广泛承认以及设想有冥冥之力可以摆布自己一生命运。",
        "type":"result",
        "options":["揭晓报告"]
      },

    ]
  },
  actions:{
    setUser({commit,state},user){
      commit('changeUser',user)
    },
    indexIncrement({commit,state},index){
      commit('indexIncrement',index)
    }
  },
  mutations:{
    changeUser(state,user) {
      state.user = user
    },
    indexIncrement(state,index){
      state.index++
      console.log(state.index)
      console.log(store.getters.currentItem)
    }
  },
  getters:{
    currentItem: state => {
      if(state.index>10){
        return {
          "id":"100",
          "question":"",
          "type":"selection",
          "options":[]
        }
      }
      return state.items[state.index];
    }
  }

})

export default store
